package sz.szsmk.citizencard.ui.adapter

import android.os.Bundle
import android.view.View
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import sz.szsmk.citizencard.DaggerApplication
import sz.szsmk.citizencard.R
import sz.szsmk.citizencard.model.network.bean.response.CollecQueryRes
import sz.szsmk.citizencard.ui.activity.IMainActivity
import sz.szsmk.citizencard.util.GlideRoundTransform
import sz.szsmk.citizencard.util.JumpUtils
import sz.szsmk.citizencard.util.StringUtils
import java.text.DecimalFormat

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/7/13 18:13
 * description:
 */
class CollecAdapterNew : BaseQuickAdapter<CollecQueryRes.DataBean, BaseViewHolder>(R.layout.collection_item) {
    override fun convert(helper: BaseViewHolder, item: CollecQueryRes.DataBean) {
        helper.setText(R.id.user_coll_adress, item.address)
        helper.setText(R.id.user_coll_shopname, item.shopName)
        val latitude = item.latitude
        val longitude = item.longitude
        var distanceString = ""
        val beanDistance = item.distance
        val toDouble = StringUtils.convertToDouble(beanDistance, 0.0) / 1000
        val doubleToString = StringUtils.doubleToString(toDouble)
        helper.setText(R.id.user_coll_distance, "距您" + doubleToString + "km")
        val areaId = item.serviceOfficeId
        //            Glide.with(mContext)
//                    .load(dataBean.getPicUrl())
//                    .centerCrop()
//                    .override(100, 100)
//                    .transform(new GlideRoundTransform(mContext))
//                    .into(binding.sev);
        Glide.with(mContext)
                .load(item.picUrl)
                .error(R.drawable.zhanweitu)
                .placeholder(R.drawable.zhanweitu)
                .centerCrop()
                .override(100, 100)
                .transform(GlideRoundTransform(mContext))
                .into(helper.getView<View>(R.id.sev) as ImageView)
        helper.getView<View>(R.id.all_type_rl).setOnClickListener {
            val bundle = Bundle()
            bundle.putInt("id", areaId)
            bundle.putString("type", "coll")
            bundle.putDouble("latitude", latitude)
            bundle.putDouble("longitude", longitude)
            JumpUtils.jumptoNatvie(mContext, "netdetail", 0, bundle)
        }
    }
}